package com.blue.http.message;

import java.util.HashMap;
import java.util.Map;

import com.blue.http.config.ErrorConfig;

/**
 * HTTP 请求响应默认实现类
 * 
 * @author zhengj
 * @since 1.0 2017年3月1日
 */
public class DefaultHttpResponse implements HttpResponse
{
	private String result;

	private Exception exception;
	private int code = ErrorConfig.SUCCESS;
	private String msg;
	private String extmsg;
	private String uri;
	private Download download;
	private Map<String, String> cookieMap = new HashMap<>();

	public DefaultHttpResponse()
	{
	}

	public DefaultHttpResponse(String result)
	{
		this.result = result;
	}

	public DefaultHttpResponse(Exception exception)
	{
		this.exception = exception;
	}

	public DefaultHttpResponse(int code, String msg, String extmsg)
	{
		this.code = code;
		this.msg = msg;
		this.extmsg = extmsg;
	}

	@Override
	public String getResult()
	{
		return result;
	}

	@Override
	public void setResult(String result)
	{
		this.result = result;
	}

	@Override
	public Exception getException()
	{
		return exception;
	}

	@Override
	public void setException(Exception exception)
	{
		this.exception = exception;
	}

	@Override
	public int getCode()
	{
		return code;
	}

	@Override
	public void setCode(int code)
	{
		this.code = code;
	}

	@Override
	public String getMsg()
	{
		return msg;
	}

	@Override
	public void setMsg(String msg)
	{
		this.msg = msg;
	}

	@Override
	public String getExtmsg()
	{
		return extmsg;
	}

	@Override
	public void setExtmsg(String extmsg)
	{
		this.extmsg = extmsg;
	}

	@Override
	public void setLocation(String uri)
	{
		this.uri = uri;
	}

	@Override
	public String getLocation()
	{
		return uri;
	}

	@Override
	public boolean isLocation()
	{
		return uri != null && !uri.isEmpty();
	}

	@Override
	public void setDownload(Download download)
	{
		this.download = download;
	}

	@Override
	public Download getDownload()
	{
		return download;
	}

	@Override
	public void setCookie(String name, String value)
	{
		cookieMap.put(name, value);
	}

	@Override
	public void removeCookie(String name)
	{
		cookieMap.remove(name);
	}

	@Override
	public Map<String, String> getCookie()
	{
		return cookieMap;
	}

}
